package pri.zxx.learndemo.designmodels.strategymodel;

import pri.zxx.learndemo.designmodels.strategymodel.sms.SmsContent;
import pri.zxx.learndemo.designmodels.strategymodel.wx.WxContent;

import java.util.Map;

enum StrategyFactory {
    SMS, WX;

    public MsgStrategy create() {
        switch (this) {
            case SMS:
                return new SmsStrategy();
            case WX:
                return new WxStrategy();
            default:
                return null;
        }
    }
}

/**
 * @author Twilight
 * @desc
 * @createTime 2020-06-09-20:47
 */
public interface MsgStrategy {
    MsgTemplate getTemplate(String appId, String to, String temId, Map<String, Object> params);
}

class SmsStrategy implements MsgStrategy {
    @Override
    public MsgTemplate getTemplate(String appId, String to, String temId, Map<String, Object> params) {
        return new MsgTemplate(appId, to, new SmsContent(temId, params));
    }
}

class WxStrategy implements MsgStrategy {
    @Override
    public MsgTemplate getTemplate(String appId, String to, String temId, Map<String, Object> params) {
        return new MsgTemplate(appId, to, new WxContent(params, temId));
    }
}